package NetWork;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-08-13
 * Time: 16:29
 */
public class UdpDictServer extends UdpEchoServer {
    private Map<String,String> dict = new HashMap<>();
    public UdpDictServer(int port) throws SocketException {
        super(port);
        dict.put("cat","小猫");
        dict.put("apple","苹果");
        dict.put("石方旭","进大厂");
    }


    @Override
    public String process(String request) {
        return dict.getOrDefault(request,"不知道");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer udpDictServer = new UdpDictServer(8000);
        udpDictServer.start();
    }


}
